from .logs import getLogger
import os, time

async def log_requests(request, call_next):
    logger = getLogger(name=os.environ.get('APP_NAME'))
    stat_time = time.time()
    response = await call_next(request)
    process_time = (time.time() - stat_time) * 1000
    format_process_time = '{0:.10f}'.format(process_time)
    logger.info(f"path={request.url.path}, timer={format_process_time}毫秒, status_code = {response.status_code}")
    return response



